package com.zhuss.core.upload;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.core.upload.DeleteUploadBo;
import com.zhuss.bean.bo.core.upload.DownloadBo;
import com.zhuss.bean.bo.core.upload.UploadBo;
import com.zhuss.bean.vo.core.upload.DownloadVo;
import com.zhuss.bean.vo.core.upload.UploadVo;
import com.zhuss.common.Processor;
import com.zhuss.common.UploadOperateService;
import com.zhuss.exception.AabException;

/**
 * 文件service（基本操作）
 * @author zhushanshuo
 * @Date 2020-02-25 15:59
 *
 */
@Component("uploadService")
public class UploadService implements UploadOperateService<Object, Object> {
	
	
	@Autowired
	@Qualifier("uploadProcessor")
	private Processor<UploadVo, UploadBo> uploadProcessor;
	
	@Autowired
	@Qualifier("downloadProcessor")
	private Processor<DownloadVo, DownloadBo> downloadProcessor;
	
	@Autowired
	@Qualifier("uploadDeleteProcessor")
	private Processor<Object, DeleteUploadBo> uploadDeleteProcessor;
	
	/**
	 * 上传
	 */
	@Override
	public Object upload(Object param) throws AabException {
		
		UploadBo bo = (UploadBo) param;
		Object result = uploadProcessor.process(bo);
		return result;
	}
	
	/**
	 * 下载
	 */
	@Override
	public Object download(Object param) throws AabException {
		
		DownloadBo bo = (DownloadBo) param;
		Object result = downloadProcessor.process(bo);
		return result;
	}
	
	/**
	 * 删除
	 */
	@Override
	public Object delete(Object param) throws AabException {
		
		DeleteUploadBo bo = (DeleteUploadBo) param;
		Object result = uploadDeleteProcessor.process(bo);
		return result;
	}
	
}

